class ElementShieldFire extends ShieldFire;

var int MinManaUsage, MaxManaUsage;

function DoFireEffect()
{
  local Vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
  local Rotator Aim;
  local Actor Other;
  local float Scale, Damage, Force;
  local EnferiPawn ep;
  local int Mana;

  Instigator.MakeNoise(1.0);
  Weapon.GetViewAxes(X,Y,Z);
  bAutoRelease = false;

  if ( (AutoHitPawn != None) && (Level.TimeSeconds - AutoHitTime < 0.15) )
  {
    Other = AutoHitPawn;
    HitLocation = Other.Location;
    AutoHitPawn = None;
  }
  else
  {
    StartTrace = Instigator.Location;
    Aim = AdjustAim(StartTrace, AimError);
    EndTrace = StartTrace + ShieldRange * Vector(Aim);
    Other = Weapon.Trace(HitLocation, HitNormal, EndTrace, StartTrace, true);
  }

    scale = (FClamp(HoldTime, MinHoldTime, FullyChargedTime) - MinHoldTime) / (FullyChargedTime - MinHoldTime); // result 0 to 1
    Damage = MinDamage + Scale * (MaxDamage - MinDamage);
    Force = MinForce + scale * (MaxForce - MinForce);
    Mana = int(MinManaUsage + scale * (MaxManaUsage - MinManaUsage));

    if (EnyaraPlayerController(Instigator.Controller) != none)
      EnyaraPlayerController(Instigator.Controller).useMana(Mana);
      Level.GetLocalPlayerController().ClientMessage("Mana: "$Mana);

    Instigator.AmbientSound = None;
    Instigator.SoundVolume = Instigator.Default.SoundVolume;

    if (ChargingEmitter != None)
        ChargingEmitter.mRegenPause = true;

     foreach Instigator.RadiusActors(class'Actor', Other, 500.00, Instigator.Location) {
       if ( Other.IsA('KActor') )
         KActor(Other).KAddImpulse(Force * (X + vect(0,0,0.5)), vect(0,0,0));

       if ( Pawn(Other) != None && Other != Instigator || (Decoration(Other) != None && Decoration(Other).bDamageable) )
         Other.TakeDamage(Damage, Instigator, HitLocation, Force*(X+vect(0,0,0.5)), DamageType);

     }

    SetTimer(0, false);
}

defaultproperties
{
     MinManaUsage=5
     MaxManaUsage=15
     DamageType=Class'XWeapons.DamTypeShieldImpact'
     ShieldRange=112.000000
     MinHoldTime=0.400000
     MinForce=65000.000000
     MaxForce=100000.000000
     MinDamage=40.000000
     MaxDamage=100.000000
     ChargingSound=Sound'WeaponSounds.Misc.shieldgun_charge'
     AutoFireTestFreq=0.150000
     FullyChargedTime=2.500000
     ChargingSoundVolume=200
     ChargingForce="shieldgun_charge"
     bFireOnRelease=True
     TransientSoundVolume=1.000000
     PreFireAnim="Charge"
     FireLoopAnim=
     FireEndAnim=
     TweenTime=0.000000
     FireSound=ProceduralSound'WeaponSounds.PShieldGunFire.P1ShieldGunFire'
     FireForce="ShieldGunFire"
     FireRate=0.600000
     AmmoClass=Class'XWeapons.ShieldAmmo'
     ShakeRotTime=2.000000
     ShakeOffsetMag=(X=-20.000000)
     ShakeOffsetRate=(X=-1000.000000)
     ShakeOffsetTime=2.000000
     BotRefireRate=1.000000
     WarnTargetPct=0.100000
     FlashEmitterClass=Class'Enyara.EffectDirtTrail'
}
